package com.xxx2;

import org.junit.Test;

import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class TestLambda {

    List<Employee> emps= Arrays.asList(
      new Employee(101,"张三",18,9999.99),
      new Employee(102,"李四",59,6666.33),
      new Employee(103,"abc",38,3333.66),
      new Employee(104,"赵六",10,7777.11),
      new Employee(105,"bcd",38,5555.22)
    );
    @Test
    public void test1(){
        Collections.sort(emps, (emp1,emp2)->{
            int i = emp1.getAge().compareTo(emp2.getAge());
            i=i==0?emp1.getName().compareTo(emp2.getName()):i;
            return i;
        });
        emps.forEach(System.out::println);
    }
}
